package org.androbuzz;

import android.content.Context;
import android.database.Cursor;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.CursorAdapter;
import android.widget.TextView;

public class AndroBuzzWebViewCursorAdapter extends CursorAdapter {
	
	private LayoutInflater inflater;
	public AndroBuzzWebViewCursorAdapter(Context context, Cursor c) {
		super(context, c);
		inflater = LayoutInflater.from(context);
	}
 
	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		TextView summary = (TextView)view.findViewById(R.id.text1);
		summary.setText(cursor.getString(
				cursor.getColumnIndex(AndroBuzzDbAdapter.KEY_AUTHOR_NAME)));
		TextView summary2 = (TextView)view.findViewById(R.id.text2);
		summary2.setText(cursor.getString(
				cursor.getColumnIndex(AndroBuzzDbAdapter.KEY_DATE)));
		WebView summary3 = (WebView)view.findViewById(R.id.webview1);
		summary3.loadDataWithBaseURL (null,"<body bgcolor=\"black\"><font color=\"white\">" + cursor.getString(
				cursor.getColumnIndex(AndroBuzzDbAdapter.KEY_SUMMARY)) + "</font></body>", "text/html", "utf-8", 
		null); 
		/*summary3.loadData(cursor.getString(
				cursor.getColumnIndex(AndroBuzzDbAdapter.KEY_CONTENT)), "text/html", "");*/
	}
 
	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		return inflater.inflate(R.layout.feed_row_webview, parent, false);
	}
}